package org.languageguide.readings;

/**
 * Split a translated reading into two parts:  
 * 1.) The body which consists of the text of the readings 
 * 2.) The translations and definitions 
 * 
 * The div which is used for the context menu marks the boundary between the two parts.
 *
 * @author Tom Blackmon
 */

class ReadingDivider{
	
	private String translations;
	private String textPart;
	
	public ReadingDivider(String reading){
		splitReading(reading);
	}
	
	public String getBody(){
		return textPart;
	}
	
	public String getTranslations(){
		return translations;
	}
	
	private void splitReading(String textToProcess){
		int loc = textToProcess.indexOf("<div id=\"context_menu\"");
		if (loc != -1){
			textPart = textToProcess.substring(0, loc);
			translations = textToProcess.substring(loc);
		}
		else{
			textPart = textToProcess;
			translations = "";
		}
	}
}